<?php
require_once('lib/PHPMailer/class.phpmailer.php');
function enviarEmail($to, $to_name, $from, $from_name, $assunto, $mensagem)
{
	$mail             = new PHPMailer(); // defaults to using php "mail()"
	$mail->IsMail();
	$mail->WordWrap = 50;                              // set word wrap
	$mail->IsHTML(true);                               // send as HTML
	
	$mail->Subject    = $assunto;            // assunto	
	//$mensagem = preg_replace("/(\\r)?\\n/i", "<br/>", $_REQUEST["mensagem"]);
	$body = $mensagem;
	
	//$body = eregi_replace("[\]",'',$body);
	
	$mail->From = $from;
	$mail->FromName = $from_name;
	$mail->AddReplyTo($from,$from_name);
	$address = $to;
	$mail->AddAddress($address, $to_name);
	
	$mail->Body = $body;
	$mail->AltBody  =  "This is the text-only body";
	
	if(!$mail->Send()) {
	  return "Mailer Error: " . $mail->ErrorInfo;
	} else {
	  return "";
	}
}
?>